package org.java.bo;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

public class Show<T> {
	public String toString(T t) {
		try {
			Field[] fields = t.getClass().getDeclaredFields();
			StringBuffer data = new StringBuffer();
			for (Field field : fields) {
				try {
					PropertyDescriptor pd = new PropertyDescriptor(
							field.getName(), t.getClass());
					String modifier = Modifier.toString(field.getModifiers());
					if (modifier.indexOf("static") < 0) {
						data.append(field.getName()).append("[")
								.append(pd.getReadMethod().invoke(t))
								.append("] ");

					}
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
			return data.toString();
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
}
